//
//  VerificationCode.m
//  MUBATE
//
//  Created by sunbin on 2017/2/15.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "VerificationCode.h"

@implementation VerificationCode

- (void)awakeFromNib{

    //文本输入框
    [_enterScode leftViewModeWithConstrainedToWidth:200.f text:NSLocalizedString(@"verification code", @"verification code") fon:Launch_textLeftViewFon setFont:Launch_textFon leftTextColor:[UIColor leftTextColor] bodyTextColor:[UIColor bodyTextColor] PlaceholderColor:[UIColor PlaceholderColor] setPlaceholder:NSLocalizedString(@"enter your scode" ,@"enter your scode") isLaunch:YES];
    
    //按钮
    [NHUtils setButton:_confirmBtn isLaunch:YES setTitle:NSLocalizedString(@"confirm", @"confirm") setLayerCornerRadius:0 setFont:Launch_confirmBtnFon];
    _confirmBtn.enabled = NO;
    
    
}


+ (instancetype)LoadVerificationCodeView{
    VerificationCode *verificationCodeView = [self loadFromNib];
    return verificationCodeView;
}


+ (instancetype)loadFromNib{
    
    NSArray *objects = [[NSBundle mainBundle] loadNibNamed:@"VerificationCode" owner:nil options:nil];
    return [objects lastObject];
}
// 按钮事件触发 7 8 9
- (IBAction)btnEven:(UIButton *)sender {
    [self endEditing:YES];
    NSInteger tag = sender.tag-7;
    if (self.nextStepHandler) {
        self.nextStepHandler(_enterScode.text ,tag);
    }
}


- (IBAction)editingChanged:(UITextField *)sender {
    if (![NHUtils isBlankString:_enterScode.text]) {
        self.confirmBtn.enabled = YES;
    }}

#pragma make UITextFieldDelegate
// textFieldShouldReturn
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    if (![NHUtils isBlankString:_enterScode.text]) {
        [self btnEven:_confirmBtn];
    }
    return YES;
}




@end
